﻿using d1Common.WebController;
using d1Project.Modules.Common.do4A.Domain;
using d1Project.Modules.Common.do4A.Models;
using d1Project.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace d1Project.Modules.Common.do4A.Controllers.a1
{
    [Route("do4A/a1/Token")]
    public class TokensController : ControllerBase
    {
        protected override DbContext dbContext
        {
            get
            {
                return null;
            }
        }

        public IHttpActionResult Post(TokenPostVm model)
        {
            if (!ModelState.IsValid) this.Error("请求参数不正确");
            string accessToken = AuthenticationMgr.Instance.CheckToken1(model.id, model.pwd);
            return Ok(new { accessToken = accessToken });
        }
    }

    public class TokenPostVm
    {
        /// <summary>
        /// id
        /// </summary>
        [Required]
        public string id { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [Required]
        public string pwd { get; set; }
    }
}
